import request from '@/utils/request'
import config from '@/config/defaultSettings'

const api = {
    productList: config.urlForService + '/jfcloud-mall-product/product/list',
    productType: config.urlForService + '/jfcloud-mall-product/product/types',
    getToken: config.urlForService + '/jfcloud-mall-user/token/simple/grant',
    validateAndGet: config.urlForService + '/jfcloud-mall-user/token/simple/validateAndGet',
    createOrder: config.urlForService + '/jfcloud-mall-order/order/create',
  }
  
  export default api

export function getProductList (parameter) {
    return request({
      url: api.productList,
      method: 'get',
      params: parameter
    })
  }

export function getProductType (parameter) {
    return request({
        url: api.productType,
        method: 'get',
        params: parameter
    })
}

export function getToken (parameter) {
  return request({
      url: api.getToken,
      method: 'post',
      data: parameter
  })
}

export function validateAndGet (parameter) {
  return request({
      url: api.validateAndGet,
      method: 'get',
      params: parameter
  })
}

export function createOrder (parameter) {
  return request({
      url: api.createOrder,
      method: 'post',
      data: parameter
  })
}